using System.Xml;
using SharpObjects.Logging;
using SharpObjects.Configuration;
using SharpObjects.Configuration.ConfigurationProviders;

namespace SharpObjects.Logging.Formatters
{
	public abstract class LogFormatterBase : ILogFormatter
	{
		public abstract class Tags
		{
			public const string message_separator = "message_separator";
			public const string value_delimiter = "value_delimiter";
		}

		protected string messageSeparator = "_______________________________________________________________________";
		protected string valueDelimiter = " | ";

        #region ILogFormatter Members

		public string MessageSeparator { get { return this.messageSeparator; } set { this.messageSeparator = value; } }
		public string ValueDelimiter { get { return this.valueDelimiter; } set { this.valueDelimiter= value; } }
        public abstract string ApplyFormat(ILogEntry logEntry);

        #endregion

        #region IXmlInitializable Members

        public virtual void Initialize(XmlElement initializationElement)
		{
			IConfigurationProvider init = new XmlConfigurationProvider(initializationElement);
			this.messageSeparator = init.GetString(Tags.message_separator, this.messageSeparator);
			this.valueDelimiter = init.GetString(Tags.value_delimiter, this.valueDelimiter);

            this.IsInitialized = true;
        }

        public bool IsInitialized { get; set; }



        #endregion
    }
}
